/**
 * 
 */
package com.dycn.posdashboard.util;

import net.sf.json.JsonConfig;
import net.sf.json.processors.JsDateJsonBeanProcessor;
import net.sf.json.util.CycleDetectionStrategy;

/**
 * @author gongqiyi
 *
 */
public class JSONObjectHelp {

	private static JsonConfig config=null;
	
	public static JsonConfig getJsonConfig(){
		
		if(config==null){
			config = new JsonConfig();
		    config.setIgnoreDefaultExcludes(false);  
		    //returns empty array and null object
		    config.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);
//		    config.registerJsonBeanProcessor(Date.class,  
//		            new JsDateJsonBeanProcessor()); // 当输出时间格式时，采用和JS兼容的格式输出
		    JsDateJsonBeanProcessor someJsDateJsonBeanProcessor=new JsDateJsonBeanProcessor();
	        config.registerJsonBeanProcessor(java.util.Date.class, someJsDateJsonBeanProcessor);
	        config.registerJsonBeanProcessor(java.sql.Date.class,someJsDateJsonBeanProcessor);
		}

	    return config;
	}
}
